Answer
In this exercise, we will:
rocker/rstudio:4.4.1 imagerstudio/home directoryBefore you start, make sure that your terminal emulator is in your project’s root directory by using pwd. If you are not in the correct folder, use cd to navigate to the root directory of your folder.
At the command line, execute the following command.
docker run -it rocker/rstudio:4.4.1 bash
When you execute this command, docker will check for the existence of the image on your computer. The first time you run this command, you likely will not have downloaded the rocker/rstudio:4.4.1 image from docker hub. As a result, the command will automatically download the image for you. While the image downloads you will see various status updates that look like this:
Unable to find image 'rocker/tidyverse:4.4.1' locally
4.4.1: Pulling from rocker/tidyverse
7646c8da3324: Pull complete
2a532d0e6beb: Pull complete
After the image has finished downloading, you will notice that your command prompt has changed to look something like this:
root@1d09e8db1e4d:/#
You have opened a terminal emulator inside a running container!
The first thing we will do is explore the file system. You should see that when you run pwd your working directory is /, i.e., the root directory.
If you use ls to list the contents of / you will see:
bin etc lib libexec mnt rocker_scripts sbin tmp
boot home lib32 libx32 opt root srv usr
dev init lib64 media proc run sys var
This is the file system for the container. I.e., none of these directories are permanently stored in your computer’s file system. They only exist for as long as the container is running.
We will care about one directory in particular for future exercises: the /home/rstudio directory. Confirm that you can navigate to this directory by executing:
cd /home/rstudio
Use ls -a
Answer